/* 
 * File:   BlockingQueueEvent.h
 * Author: lgr013
 *
 * Created on 2 de noviembre de 2014, 16:03
 */

#ifndef BLOCKINGQUEUEEVENT_H
#define	BLOCKINGQUEUEEVENT_H

#include <queue>
#include <mutex>
#include <condition_variable>
#include "../Define/Structs.h"
#include <iostream>

using namespace std;

class BlockingQueueEvent {
private:
    mutable std::mutex mtx;
    std::condition_variable cv;
    std::queue<struct Event> queue;
    bool flag;
//    bool pushing;
    
public:
    BlockingQueueEvent();
    
    void push(struct Event data);
    struct Event pop();
    
    struct Event waitAndPop(bool init);
    bool tryPop(struct Event &data);
    
    bool empty();
    int size();
    
    virtual ~BlockingQueueEvent();

};

#endif	/* BLOCKINGQUEUEEVENT_H */

